;(function(){
  function makeIterator(array){
    var nextIndex = 0;
    return {
      next: function(){
        return nextIndex < array.length ? 
        {value : array[nextIndex++], done: false} : 
        {value: undefined, done: true}
      }
    }
  }

  var item = makeIterator([1, 2, 3, 4]);
  console.log(item.next());
  console.log(item.next());
  console.log(item.next());
  console.log(item.next());


  var obj = {
    staic: [1,5,8,2],
    end: [4,5,6,7],
    [Symbol.iterator](){
      let index = 0,
      arr = [...this.staic, ...this.end],
      len = arr.length;
      return {
        next(){
          if(index < len){
            return {
              value: arr[index++],
              done: false,
            }
          }else{
            return {
              value: undefined,
              done: true,
            }
          }
        }
      }
    }
  }

  for(let i of obj){
    console.log(i);
  }
})()